package com.mentaleye.biz.impl;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mentaleye.bean.TimeTableBean;
import com.mentaleye.biz.TimeTableBiz;
import com.mentaleye.dal.model.TimeTableExample;
import com.mentaleye.service.TimeTableService;
import com.mentaleye.util.CommonResult;

@Service
public class TimeTableBizImpl implements TimeTableBiz{

	@Autowired private TimeTableService timeTableService;
	
	private static Logger logger = Logger.getLogger(TimeTableBizImpl.class);
	
	public CommonResult addByBean(TimeTableBean timeTableBean){
		boolean success = false;
		try {
			success = timeTableService.add(timeTableBean);
		} catch (Exception e) {
			logger.error("添加课表课程异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult addList(List<TimeTableBean> list){
		boolean success = false;
		try {
			success = timeTableService.addList(list);
		} catch (Exception e) {
			logger.error("批量添加课表课程异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult removeById(Integer id){
		boolean success = false;
		try {
			success = timeTableService.removeById(id);
		} catch (Exception e) {
			logger.error("根据ID删除课表课程异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult removeByTimeTableId(Integer timeTableId){
		boolean success = false;
		try {
			success = timeTableService.removeByTimeTableId(timeTableId);
		} catch (Exception e) {
			logger.error("根据课表编号删除异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult removeByTime(Integer curriculumId, String beginTime, String endTime){
		boolean success = false;
		try {
			success = timeTableService.removeByTime(curriculumId, beginTime, endTime);
		} catch (Exception e) {
			logger.error("根据时间删除异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult removeByExample(TimeTableExample example){
		boolean success = false;
		try {
			success = timeTableService.removeByExample(example);
		} catch (Exception e) {
			logger.error("根据条件删除异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult removeByIdList(List<Integer> ids){
		boolean success = false;
		try {
			success = timeTableService.removeList(ids);
		} catch (Exception e) {
			logger.error("批量删除异常", e);
		}
		return new CommonResult(success);
	}

	public CommonResult removeByClassIdList(List<Integer> oaclassIds){
		boolean success = false;
		try {
			success = timeTableService.removeByClassIdList(oaclassIds);
		} catch (Exception e) {
			logger.error("根据班级批量删除异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult modify(TimeTableBean timeTableBean){
		boolean success = false;
		try {
			success = timeTableService.modify(timeTableBean);
		} catch (Exception e) {
			logger.error("修改课表课程异常", e);
		}
		return new CommonResult(success);
	}

	public CommonResult modifyTeacherByMap(Map<String,Object> map){
		boolean success = false;
		try {
			success = timeTableService.modifyTeacherByMap(map);
		} catch (Exception e) {
			logger.error("修改课程教师异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult modifyByList(List<TimeTableBean> list){
		boolean success = false;
		try {
			success = timeTableService.modifyByList(list);
		} catch (Exception e) {
			logger.error("批量修改课程表异常", e);
		}
		return new CommonResult(success);
	}
	
	public CommonResult modifyByExample(TimeTableBean timeTableBean,TimeTableExample example){
		boolean success = false;
		try {
			success = timeTableService.modifyByExample(timeTableBean, example);
		} catch (Exception e) {
			logger.error("条件修改课程表异常", e);
		}
		return new CommonResult(success);
	}
	
	public TimeTableBean queryById(Integer id){
		return timeTableService.queryById(id);
	}
	
	public List<TimeTableBean> queryByClassId(int oaClassId){
		return timeTableService.queryByClassId(oaClassId);
	}
	
	public List<TimeTableBean> queryByTimeTableId(Integer timeTableId){
		return timeTableService.queryByTimeTableId(timeTableId);
	}
	
	public List<TimeTableBean> queryByExample(TimeTableExample example){
		return timeTableService.queryByExample(example);
	}
	
	public List<TimeTableBean> queryByBeginTime(Integer timeTableId,String beginTime){
		return timeTableService.queryByBeginTime(timeTableId, beginTime);
	}
}
